package utils

import "reflect"

// InterfaceToArray 转换任意interface{}为数组interface{}
func InterfaceToArray(records interface{}) []interface{} {
	// 仅支持切片
	t := reflect.TypeOf(records)

	if t.Kind() != reflect.Slice {
		return []interface{}{records}
	}
	tv := reflect.ValueOf(records)
	var list []interface{}
	for i := 0; i < tv.Len(); i++ {
		list = append(list, tv.Index(i).Interface())
	}
	return list
}
